﻿package mortal.game.view.pack.other
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.mvc.interfaces.*;

    public class MulSelectPackageWin extends SmallWindow
    {
        private var _itemData:ItemData;
        private var _bg:GImageBitmap;
        private var _rewardBg:ScaleBitmap;
        private var _list:GTileList;
        private var _txt:GTextFiled;
        private static var _instance:MulSelectPackageWin;

        public function MulSelectPackageWin(param1:ILayer = null)
        {
            if (_instance != null)
            {
                throw new Error(" MulSelectPackageWin 单例 ");
            }
            return;
        }// end function

        public function set itemData(param1:ItemData) : void
        {
            this._itemData = param1;
            this._list.dataProvider = this.getBuyDataProvider();
            this.title = Language.getString(35470);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.setSize(720, 430);
            this._bg = UIFactory.gImageBitmap("", 17, 40, this);
            LoaderHelp.setBitmapdata("MulSelevtBg.swf", this._bg);
            this.pushUIToDisposeVec(UIFactory.bg(250, 113, 443, 268, this, ImagesConst.LevelBg));
            this.pushUIToDisposeVec(UIFactory.bg(250, 110 + 138, 443, 1, this, ImagesConst.SplitLine));
            this._list = UIFactory.tileList(273, 107, 410, 270, this);
            this._list.columnWidth = 90;
            this._list.rowHeight = 131;
            this._list.horizontalGap = 15;
            this._list.verticalGap = -2;
            this._list.setStyle("cellRenderer", MulSelectCellRender);
            this._list.isClickedUpdate = false;
            this._list.isChangeUpdate = false;
            this._list.isClickedUpdate = false;
            LoaderHelp.addResCallBack(ResFileConst.mulSelectPackage, this.showSkin);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg.dispose(param1);
            this._bg = null;
            this._list.dispose(param1);
            this._list = null;
            if (this._rewardBg)
            {
                this._rewardBg.dispose(param1);
                this._rewardBg = null;
            }
            return;
        }// end function

        private function showSkin() : void
        {
            if (isDisposed)
            {
                return;
            }
            this._rewardBg = GlobalClass.getScaleBitmap(ImagesConst.mulSelectPackageBg, new Rectangle(44, 29, 1, 1));
            this._rewardBg.x = 245;
            this._rewardBg.y = 80;
            this._rewardBg.setSize(455, 305);
            addChild(this._rewardBg);
            addChild(this._list);
            var _loc_1:* = GlobalStyle.textFormatItemGreen;
            _loc_1.size = 15;
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(35471), 260, 86, 320, 50, this, _loc_1));
            return;
        }// end function

        private function getBuyDataProvider() : DataProvider
        {
            var _loc_3:int = 0;
            var _loc_4:Object = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:* = (this._itemData.itemInfo as ItemGiftBagInfo).itemList.split("&");
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_4 = {data:_loc_2[_loc_3], item:this._itemData};
                _loc_1.addItem(_loc_4);
                _loc_3++;
            }
            return _loc_1;
        }// end function

        override protected function closeBtnClickHandler(event:MouseEvent) : void
        {
            if (GiftsUtil.currentGiftType)
            {
                GiftsUtil.notToUseGiftDic[GiftsUtil.currentGiftType] = true;
                GiftsUtil.currentGiftType = "";
            }
            super.closeBtnClickHandler(event);
            return;
        }// end function

        public static function get instance() : MulSelectPackageWin
        {
            if (_instance == null)
            {
                _instance = new MulSelectPackageWin;
                _instance.layer = LayerManager.fullScreenTopLayer;
            }
            return _instance;
        }// end function

    }
}
